//
//  ViewController.m
//  09-catransition转场动画
//
//  Created by J on 16/2/24.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"
static NSUInteger i = 1;
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //转场代码
    if (i==4) {
        i=1;
    }
    //加载图片名称
    NSString* imageN = [NSString stringWithFormat:@"%d",i];
    _imageView.image = [UIImage imageNamed:imageN];
    
    i++;
    
    
    //转场动画  // * `fade', `moveIn', `push' and `reveal'. Defaults to `fade'.  suckEffect从父控件左上角抽走 要从自己左上角 就做个父控件和自己一样大就行了*/

    CATransition * ani = [CATransition animation];
    ani.duration = 0.5;
    ani.type = @"suckEffect";
    [_imageView.layer addAnimation:ani forKey:nil];
    

}

@end
